home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / quartz / q0430.dms / q0430.adf / Patch / common.h < prev    next >
C/C++ Source or Header  |  1992-09-02  |  5KB  |  192 lines

  1. /* $Header: common.h,v 2.0.1.2 88/06/22 20:44:53 lwall Locked $
  2.  *
  3.  * $Log:        common.h,v $
  4.  * Revision 2.0.1.2  88/06/22  20:44:53  lwall
  5.  * patch12: sprintf was declared wrong
  6.  *
  7.  * Revision 2.0.1.1  88/06/03  15:01:56  lwall
  8.  * patch10: support for shorter extensions.
  9.  *
  10.  * Revision 2.0  86/09/17  15:36:39  lwall
  11.  * Baseline for netwide release.
  12.  *
  13.  */
  14.  
  15. #define DEBUGGING
  16.  
  17. #include "config.h"
  18.  
  19. /* shut lint up about the following when return value ignored */
  20.  
  21. extern char *fgets();
  22.  
  23. #define Signal (void)signal
  24. #define Unlink (void)unlink
  25. #define Lseek (void)lseek
  26. #define Fseek (void)fseek
  27.  
  28.  
  29. #ifndef AMIGA
  30. #define Fstat (void)fstat
  31. #else
  32. #define Fstat %%%%%%%%%%%
  33. #endif
  34.  
  35. #ifdef AMIGA
  36. #define popen open
  37. #define Pclose (void)close
  38. #else
  39. #define Pclose (void)pclose
  40. #endif
  41.  
  42. #define Close (void)close
  43. #define Fclose (void)fclose
  44. #define Fflush (void)fflush
  45. #define Sprintf (void)sprintf
  46. #define Mktemp (void)mktemp
  47. #define Strcpy (void)strcpy
  48. #define Strcat (void)strcat
  49.  
  50. #include <stdio.h>
  51. #include <assert.h>
  52.  
  53. #ifndef AMIGA
  54. #include <sys/stat.h> */
  55. #include <sys/types.h>
  56.  
  57. #else
  58. #include "stat.h"
  59. #include <fcntl.h>
  60. #endif
  61.  
  62.  
  63. #include <ctype.h>
  64. /* #include <signal.h> */
  65.  
  66. /* constants */
  67.  
  68. #define TRUE (1)
  69. #define FALSE (0)
  70.  
  71. #define MAXHUNKSIZE 100000              /* is this enough lines? */
  72. #define INITHUNKMAX 125                 /* initial dynamic allocation size */
  73. #define MAXLINELEN 1024
  74. #define BUFFERSIZE 1024
  75. #define SCCSPREFIX "s."
  76. #define GET "get -e %s"
  77. #define RCSSUFFIX ",v"
  78. #define CHECKOUT "co -l %s"
  79.  
  80. #ifdef FLEXFILENAMES
  81. #define ORIGEXT ".orig"
  82. #define REJEXT ".rej"
  83. #else
  84. #define ORIGEXT "~"
  85. #define REJEXT "#"
  86. #endif
  87.  
  88.  
  89. /* handy definitions */
  90.  
  91. #define Null(t) ((t)0)
  92. #define Nullch Null(char *)
  93. #define Nullfp Null(FILE *)
  94. #define Nulline Null(LINENUM)
  95.  
  96. #define Ctl(ch) ((ch) & 037)
  97.  
  98. #define strNE(s1,s2) (strcmp(s1, s2))
  99. #define strEQ(s1,s2) (!strcmp(s1, s2))
  100. #define strnNE(s1,s2,l) (strncmp(s1, s2, l))
  101. #define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
  102.  
  103. /* typedefs */
  104.  
  105. typedef char bool;
  106. typedef long LINENUM;                   /* must be signed */
  107. typedef unsigned MEM;                   /* what to feed malloc */
  108.  
  109. /* globals */
  110.  
  111. EXT int Argc;                           /* guess */
  112. EXT char **Argv;
  113. EXT int Argc_last;                      /* for restarting plan_b */
  114. EXT char **Argv_last;
  115.  
  116. EXT struct stat filestat;               /* file statistics area */
  117. EXT int filemode INIT(0644);
  118.  
  119. EXT char buf[MAXLINELEN];               /* general purpose buffer */
  120. EXT FILE *ofp INIT(Nullfp);             /* output file pointer */
  121. EXT FILE *rejfp INIT(Nullfp);           /* reject file pointer */
  122.  
  123. EXT bool using_plan_a INIT(TRUE);       /* try to keep everything in memory */
  124. EXT bool out_of_mem INIT(FALSE);        /* ran out of memory in plan a */
  125.  
  126. #define MAXFILEC 2
  127. EXT int filec INIT(0);                  /* how many file arguments? */
  128. EXT char *filearg[MAXFILEC];
  129. EXT bool ok_to_create_file INIT(FALSE);
  130. EXT char *bestguess INIT(Nullch);       /* guess at correct filename */
  131.  
  132. EXT char *outname INIT(Nullch);
  133. EXT char rejname[128];
  134.  
  135. EXT char *origext INIT(Nullch);
  136. EXT char *origprae INIT(Nullch);
  137.  
  138. #ifdef AMIGA
  139. EXT char TMPOUTNAME[] INIT("T:patchoXXXXXX");
  140. EXT char TMPINNAME[] INIT("T:patchiXXXXXX"); /* might want /usr/tmp here */
  141. EXT char TMPREJNAME[] INIT("T:patchrXXXXXX");
  142. EXT char TMPPATNAME[] INIT("T:patchpXXXXXX");
  143. #else
  144. EXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX"); /* might want /usr/tmp here */
  145. EXT char TMPREJNAME[] INIT("/tmp/patchrXXXXXX");
  146. EXT char TMPPATNAME[] INIT("/tmp/patchpXXXXXX");
  147. #endif
  148.  
  149. EXT bool toutkeep INIT(FALSE);
  150. EXT bool trejkeep INIT(FALSE);
  151.  
  152. EXT LINENUM last_offset INIT(0);
  153. #ifdef DEBUGGING
  154. EXT int debug INIT(0);
  155. #endif
  156. EXT LINENUM maxfuzz INIT(2);
  157. EXT bool force INIT(FALSE);
  158. EXT bool verbose INIT(TRUE);
  159. EXT bool reverse INIT(FALSE);
  160. EXT bool noreverse INIT(FALSE);
  161. EXT bool skip_rest_of_patch INIT(FALSE);
  162. EXT int strippath INIT(957);
  163. EXT bool canonicalize INIT(FALSE);
  164.  
  165. #define CONTEXT_DIFF 1
  166. #define NORMAL_DIFF 2
  167. #define ED_DIFF 3
  168. #define NEW_CONTEXT_DIFF 4
  169. EXT int diff_type INIT(0);
  170.  
  171. EXT bool do_defines INIT(FALSE);        /* patch using ifdef, ifndef, etc. */
  172. EXT char if_defined[128];               /* #ifdef xyzzy */
  173. EXT char not_defined[128];              /* #ifndef xyzzy */
  174. EXT char else_defined[] INIT("#else\n");/* #else */
  175. EXT char end_defined[128];              /* #endif xyzzy */
  176.  
  177. EXT char *revision INIT(Nullch);        /* prerequisite revision, if any */
  178.  
  179. char *malloc();
  180. char *realloc();
  181. char *strcpy();
  182. char *strcat();
  183. char *sprintf();                /* usually */
  184. long atol();
  185. long lseek();
  186. #ifdef CHARSPRINTF
  187. char *sprintf();
  188. #else
  189. int sprintf();
  190. #endif
  191. char *mktemp();
  192.